﻿
    <div class="editor-label">
        @Helpers.TryRenderRequiredTag(ViewData.ModelMetadata.IsRequired)
        @if (ViewData["FieldTitle"] != null)
        {
            @Html.Label(ViewData["FieldTitle"].ToString())
        }
        else
        {    
            @Html.LabelFor(model => model)
        }

        @Html.ValidationMessageFor(model => model)
    </div>
    <div class="editor-field">
        @if (ViewData.ModelMetadata.ModelType == typeof(DateTime) || ViewData["ForceDate"] != null)
        {
            var g = "D" + Guid.NewGuid().ToString("N");
            var tempdate = DateTime.MinValue;
            if (ViewData.ModelMetadata.ModelType == typeof(DateTime))
            {
                tempdate = (DateTime)Model.Date;
            }
            else if (null != Model)
            {
                DateTime.TryParse(Model.ToString(), out tempdate);
            }


            
            <span class="small-input">
                @if (tempdate == DateTime.MinValue)
                {
                    <input type="date" id="@(g)" name="@ViewData.ModelMetadata.PropertyName"/>
                }
                else
                {
                    <input type="date" id="@(g)" name="@ViewData.ModelMetadata.PropertyName" value="@(tempdate.ToString("yyyy-MM-dd"))" />
                }
                @*<script type="text/javascript">                $(function () { $('#@(g)').datepicker(); });</script>*@
            </span>
        }
        else if (ViewData.ModelMetadata.ModelType == typeof(Int32))
        {
            if (Model == 0)
            {
            @Html.TextBox("", "");
            }
            else
            {
            @Html.TextBoxFor(model => model)
            }
        }
        else
        {
            @Html.TextBoxFor(model => model)
        }
        
    </div>
